package ipaintplugin.actions;

import ipaintplugin.Activator;
import ipaintplugin.objects.Figure;
import ipaintplugin.objects.Oval;
import ipaintplugin.objects.Point;
import ipaintplugin.objects.Rectangle;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.ui.PlatformUI;

public class OvalToolAction extends BaseToolAction {

	public OvalToolAction() {
		setText("Oval Tool");
		setToolTipText("Draw Oval");

		setImageDescriptor(ImageDescriptor.createFromURL(FileLocator.find(
				Platform.getBundle(Activator.PLUGIN_ID), new Path(
						"icons/oval.png"), null)));

	}

	@Override
	public Figure getFigureInstance(MouseEvent min, MouseEvent max) {
		Oval oval = new Oval();

		oval.setCenter(new Point((min.x + max.x) / 2, (min.y + max.y) / 2));
		oval.setHeight(Math.abs(max.y - min.y));
		oval.setWidth(Math.abs(max.x - min.x));

		return oval;
	}

}
